package Demo8;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-12-22
 * Time: 21:00
 */
/* 请在这里填写答案 */
class User{
    public String username;
    public String mima;

    public User(String username, String mima) {
        this.username = username;
        this.mima = mima;
    }

    @Override
    public String toString() {
        return "{ 用户名："+username+" 密码："+mima+"}";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return Objects.equals(username, user.username) && Objects.equals(mima, user.mima);
    }

    @Override
    public int hashCode() {
        return Objects.hash(username, mima);
    }
}

public class Main {
    public static void main(String[] args) {
        HashSet<User> set = new HashSet<User>();
        set.add(new User("Tom","11111"));
        set.add(new User("Jerry","22222"));
        set.add(new User("Jerry","22222"));
        set.add(new User("Marry","33333"));
        Iterator<User> it=set.iterator();
        for(;it.hasNext();)
            System.out.println(it.next());
    }
}